home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Examples / A-Z / Q / QuickDraw3D / Simple QuickDraw 3D View / UCustomViewerDocument.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  5.9 KB  |  179 lines  |  [TEXT/CWIE]

  1. //----------------------------------------------------------------------------------------
  2. // UCustomViewerDocument.cp
  3. // Copyright © 1996 by Apple Computer, Inc. All rights reserved. 
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __UCustomViewerDocument__
  7. #include "UCustomViewerDocument.h"
  8. #endif
  9.  
  10. // Sample QD3DViewer
  11.  
  12. #ifndef __UQD3DViewer__
  13. #include "UQD3DViewer.h"
  14. #endif
  15.  
  16. #ifndef __UCustomViewerWindow__
  17. #include "UCustomViewerWindow.h"
  18. #endif
  19.  
  20. // MacApp
  21.  
  22. #ifndef __UVIEWSERVER__
  23. #include "UViewServer.h"
  24. #endif
  25.  
  26. #ifndef __UWINDOW__
  27. #include "UWindow.h"
  28. #endif
  29.  
  30. //QD3D
  31. #ifndef QD3D_h
  32. #include <QD3D.h>
  33. #endif
  34.  
  35. #ifndef   QD3DViewer_h
  36. #include <QD3DViewer.h>
  37. #endif
  38.  
  39. const ResNumber kCustomWindowID = 1000;
  40.  
  41.  
  42. //========================================================================================
  43. // CLASS TCustomViewerDocument
  44. //========================================================================================
  45. #undef Inherited
  46. #define Inherited TDocument
  47.  
  48. #pragma segment AOpen
  49. MA_DEFINE_CLASS_M1(TCustomViewerDocument, Inherited);
  50.  
  51. //----------------------------------------------------------------------------------------
  52. // TCustomViewerDocument constructor 
  53. //----------------------------------------------------------------------------------------
  54. #pragma segment AOpen
  55.  
  56. TCustomViewerDocument::TCustomViewerDocument():
  57.     fQD3DView1(NULL),
  58.     fCustomViewerWindow(NULL)
  59. {
  60. } // TCustomViewerDocument::TCustomViewerDocument 
  61.  
  62. //----------------------------------------------------------------------------------------
  63. // TCustomViewerDocument::ICustomViewerDocument: 
  64. //----------------------------------------------------------------------------------------
  65. #pragma segment AOpen
  66.         
  67. void TCustomViewerDocument::ICustomViewerDocument()
  68. {
  69.     this->IDocument();
  70. } // TCustomViewerDocument::ICustomViewerDocument 
  71.  
  72. //----------------------------------------------------------------------------------------
  73. // TCustomViewerDocument destructor
  74. //----------------------------------------------------------------------------------------
  75. #pragma segment AClose
  76.  
  77. TCustomViewerDocument::~TCustomViewerDocument()
  78. {
  79. }
  80.  
  81. //----------------------------------------------------------------------------------------
  82. // TCustomViewerDocument::DoMakeViews: 
  83. //----------------------------------------------------------------------------------------
  84. #pragma segment AOpen
  85.  
  86. void TCustomViewerDocument::DoMakeViews(Boolean /*forPrinting*/) // Override 
  87. {
  88.     FailNIL(fCustomViewerWindow =(TCustomViewerWindow*) gViewServer->NewTemplateWindow(kCustomWindowID, this));
  89.     fCustomViewerWindow->fCustomViewerDocument = this;
  90.     
  91.     fQD3DView1 = (TQD3DViewerView*) (fCustomViewerWindow->FindSubView('q3d2'));
  92. } // TCustomViewerDocument::DoMakeViews 
  93.  
  94.  
  95. //----------------------------------------------------------------------------------------
  96. // TCustomViewerDocument::SetViewerFlags: 
  97. //----------------------------------------------------------------------------------------
  98.  
  99. void TCustomViewerDocument::SetViewerFlags()
  100. {
  101.     unsigned long theViewerFlags = 0;
  102.     TCheckBox* theShowBadgeCB;
  103.     TCheckBox* theViewerActiveCB;
  104.     TCheckBox* theControllerVisCB;
  105.     //TCheckBox* theDraggingOffCB;
  106.     TCheckBox* theCameraButtonCB;
  107.     TCheckBox* theTruckButtonCB;
  108.     TCheckBox* theOrbitButtonCB;
  109.     TCheckBox* theZoomButtonCB;
  110.     TCheckBox* theDollyButtonCB;
  111.  
  112.     //Check the  rendering method - NOT a viewer flag
  113.     TCheckBox* theWireFrameCB;
  114.     FailNIL(theWireFrameCB = (TCheckBox*)(fCustomViewerWindow->FindSubView('rend')));
  115.     if(theWireFrameCB->IsOn())
  116.         fQD3DView1->SetRenderer(kQ3RendererTypeWireFrame, TRUE);
  117.     else
  118.         fQD3DView1->SetRenderer(kQ3RendererTypeInteractive, TRUE);
  119.  
  120.     FailNIL(theShowBadgeCB         = (TCheckBox*)(fCustomViewerWindow->FindSubView('shBG')));
  121.     FailNIL(theViewerActiveCB     = (TCheckBox*)(fCustomViewerWindow->FindSubView('vwAC')));
  122.     FailNIL(theControllerVisCB     = (TCheckBox*)(fCustomViewerWindow->FindSubView('cVIS')));
  123.     //FailNIL(theDraggingOffCB     = (TCheckBox*)(fCustomViewerWindow->FindSubView('****')));
  124.     FailNIL(theCameraButtonCB     = (TCheckBox*)(fCustomViewerWindow->FindSubView('camB')));
  125.     FailNIL(theTruckButtonCB     = (TCheckBox*)(fCustomViewerWindow->FindSubView('truB')));
  126.     FailNIL(theOrbitButtonCB     = (TCheckBox*)(fCustomViewerWindow->FindSubView('orbB')));
  127.     FailNIL(theZoomButtonCB     = (TCheckBox*)(fCustomViewerWindow->FindSubView('zooB')));
  128.     FailNIL(theDollyButtonCB    = (TCheckBox*)(fCustomViewerWindow->FindSubView('dolB')));
  129.     
  130.     if(theShowBadgeCB->IsOn())
  131.         theViewerFlags = theViewerFlags | kQ3ViewerShowBadge;
  132.  
  133.     if(theViewerActiveCB->IsOn())
  134.         theViewerFlags = theViewerFlags | kQ3ViewerActive;
  135.         
  136.     if(theControllerVisCB->IsOn())
  137.         theViewerFlags = theViewerFlags | kQ3ViewerControllerVisible;
  138.         
  139.     if(theCameraButtonCB->IsOn())
  140.         theViewerFlags = theViewerFlags | kQ3ViewerButtonCamera;
  141.         
  142.     if(theTruckButtonCB->IsOn())
  143.         theViewerFlags = theViewerFlags | kQ3ViewerButtonTruck;
  144.         
  145.     if(theCameraButtonCB->IsOn())
  146.         theViewerFlags = theViewerFlags | kQ3ViewerButtonCamera;
  147.         
  148.     if(theOrbitButtonCB->IsOn())
  149.         theViewerFlags = theViewerFlags | kQ3ViewerButtonOrbit;
  150.         
  151.     if(theZoomButtonCB->IsOn())
  152.         theViewerFlags = theViewerFlags | kQ3ViewerButtonZoom;
  153.         
  154.     if(theDollyButtonCB->IsOn())
  155.         theViewerFlags = theViewerFlags | kQ3ViewerButtonDolly;
  156.         
  157.     fQD3DView1->SetViewerFlags(theViewerFlags);
  158. } // TCustomViewerDocument::SetViewerFlags 
  159.  
  160.  
  161. //----------------------------------------------------------------------------------------
  162. // TCustomViewerDocument::DoMakeViews: 
  163. //----------------------------------------------------------------------------------------
  164. #pragma segment AOpen
  165.  
  166. void TCustomViewerDocument::SetViewerBackground() 
  167. {
  168.     CRGBColor    newColor;
  169.     CStr255        thePrompt = "Pick a new color";
  170.     if (GetColor(kBestSystemLocation, thePrompt, NULL, newColor))
  171.     {
  172.         fQD3DView1->SetBackgroundColor(newColor,1.0,TRUE);
  173.     }
  174. } // TCustomViewerDocument::DoMakeViews 
  175.  
  176. //----------------------------------------------------------------------------------------
  177. // End of UCustomViewerDocument.cp
  178.  
  179.